<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }

    body{
        overflow: hidden;
    }

    .text{
        width: 800px;
        height: 950px;
        border: 2px solid rgb(223, 223, 223);
        padding-top: 20px;
        padding-left: 20px;
        font-size: 20px;
        color: black;
        font-weight: 900;
        line-height: 50px;
    }

    .one {
        width: 850px;
        height: 930px;
        padding-top: 20px;
        line-height: 70px;
        float: right;
    }

</style>
<body>
    <div id="app">
        <textarea class="text" v-model="val"></textarea>
        <div class="one" v-html="mark"></div>
    </div>
</body>

</html>
<script src="https://cdn.bootcdn.net/ajax/libs/marked/1.2.7/marked.min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js'></script>
<script>
    //核心方法就是marked(输入值) 这个方法会自动将输入值转换成markdown html格式
    let vm = new Vue({
        el: "#app",
        data: {
            val: "# 一级标题"
        },
        computed: {
            mark() {
                console.log(this.val)
                console.log(marked(this.val))
                return marked(this.val)
            }
        }
    })
</script>